﻿using System.Collections.Generic;

namespace RedirectManager.Interfaces
{
    using RedirectManager.Pipelines.PublishItem;

    public interface ILookupProvider
    {
        /// <summary>
        /// Gets a value indicating whether the provider supports write events (create, delete, etc)
        /// </summary>
        bool IsReadOnly { get; }

        /// <summary>
        /// Performs a lookup on the urlpath during a httpRequest
        /// </summary>
        /// <param name="requestUrlPath">
        /// The request Url Path.
        /// </param>
        /// <returns>
        /// The IRedirect record, if found.
        /// </returns>
        IRedirect LookupUrl(string requestUrlPath);

        /// <summary>
        /// Gets all IRedirect data relating to a particular item
        /// </summary>
        /// <param name="id">
        /// The sitecore item id.
        /// </param>
        /// <returns>
        /// IRedirect items
        /// </returns>
        IEnumerable<IRedirect> LookupItem(string id);

        bool Exists(string requestUrlPath);

        /// <summary>
        /// Creates a new redirect
        /// </summary>
        /// <param name="requestUrlPath">
        /// The url path to redirect
        /// </param>
        /// <param name="targetItemId">
        /// The target item ID to redirect to
        /// </param>
        /// <param name="autoGenerated">True is automatically generated
        /// </param>
        void Create(string requestUrlPath, string targetItemId, bool autoGenerated);

        /// <summary>
        /// Deletes matching redirects
        /// </summary>
        /// <param name="requestUrlPath">
        /// The request Url Path.
        /// </param>
        void Delete(string requestUrlPath);
    }
}

